<?php
class admin_util_operate{
	public static function add_operater_log($res_id,$res_type,$oper,$uid='',$username=''){
		if(is_string($res_id) && preg_match('/[\d,]+/',$res_id)){
			$res_id = explode(',',$res_id);
		}
		$res_id = is_array($res_id)?$res_id:(array)$res_id;
		$operlog = Model::factory('admin_model_operate');
		return $operlog->add_operate_log($res_id,$res_type,$oper,$uid,$username);
	}
	
	/**
	 * 生成selecthtml
	 * Enter description here ...
	 * @param unknown_type $type
	 */
	public static function getOperSelect($type=1){
		$name = 'opr';
		$op_type = $_SERVER['const']['oper_type'];		
		if($type==2){//资源类型
			$name = 'rtype';
			$op_type = $_SERVER['const']['res_type'];
		}
		$str='<select name="'.$name.'">
			<option value="0">请选择</option>
		';
		$select = '';
		foreach ($op_type AS $k=>$value){
			$select = (_($name)==$k)?'selected="selected"':'';
			$str.='<option value="'.$k.'" '.$select.' >'.$value['name'].'</option>
			';
		}
		$str.='</select>
		';
		return $str;
	}
	
}